{include file="common/head"/}
<div class="admin-main layui-anim layui-anim-upbit">
    <fieldset class="layui-elem-field layui-field-title">
        <legend>业绩统计</legend>
    </fieldset>
    <div class="demoTable">
    </div>
    <table class="layui-table" id="list" lay-filter="list"></table>
</div>
<script type="text/html" id="b1">
    {{d.b1}}%
</script>
<script type="text/html" id="b2">
    {{d.b2}}%
</script>
<script type="text/html" id="b3">
    {{d.b3}}%
</script>
<script type="text/html" id="b4">
    {{d.b4}}%
</script>
<script type="text/html" id="b5">
    {{d.b5}}%
</script>
<script type="text/html" id="b6">
    {{d.b6}}%
</script>
{include file="common/foot"/}
<script>
    layui.use(['table','form'], function() {
        var table = layui.table,form = layui.form, $ = layui.jquery;
        var tableIn = table.render({
            id: 'user',
            elem: '#list',
            url: '{:url("achievement")}',
            method: 'post',
            page: true,
            cols: [[
               // {checkbox:true,fixed: true},
                {field: 'id', title: '{:lang("编号")}', width: 40, fixed: true},
                {field: 'createtime', title: '时间', width: 170, align: 'center'},
                {field: 'newadd_user', align: 'center',title: '新增会员', width: 90},
				{field: 'all_user', align: 'center',title: '总会员', width: 90},
				{field: 'bonus1', title: '直推奖', width: 90},
				{field: 'bonus2', title: '利润奖', width: 90},
				{field: 'bonus3', title: '培育奖', width: 90},
				{field: 'bonus4', title: '报单奖', width: 90},
				{field: 'new_grant', title: '奖金发放', width: 90},
				{field: 'all_grant', title: '总发放', width: 90},
				{field: 'newadd_achievement', align: 'center',title: '新增业绩', width: 90},
				{field: 'all_achievement', align: 'center',title: '总业绩', width: 90},
				{field: 'b1', title: '直推奖拨比', width: 100,toolbar: '#b1'},
				{field: 'b2', title: '利润奖拨比', width: 100,toolbar: '#b2'},
				{field: 'b3', title: '培育奖拨比', width: 100,toolbar: '#b3'},
				{field: 'b4', title: '报单奖拨比', width: 100,toolbar: '#b4'},
				{field: 'beizhu', title: '拨比', width: 80,toolbar: '#b5'},
				{field: 'beizhu', title: '总拨比', width: 100,toolbar: '#b6'},
               // {field: 'is_ok', align: 'center',title: '提现状态', width: 120,toolbar: '#is_lock'},
               
             // {width: 160, align: 'center', toolbar: '#action'}
            ]],
            limit: 20 //每页默认显示的数量
        });
        form.on('switch(is_lock)', function(obj){
            loading =layer.load(1, {shade: [0.1,'#fff']});
            var id = this.value;
            var is_lock = obj.elem.checked===true?0:1;
            $.post('{:url("tixians")}',{'id':id,'is_lock':is_lock},function (res) {
                layer.close(loading);
                if (res.status==1) {
                    tableIn.reload();
                }else{
                    layer.msg(res.msg,{time:1000,icon:2});
                    return false;
                }
            })
        });
        //搜索
        $('#search').on('click', function() {
            var key = $('#key').val();
            if($.trim(key)==='') {
                layer.msg('{:lang("pleaseEnter")}关键字！',{icon:0});
                return;
            }
            tableIn.reload({ page: {page: 1},where: {key: key}});
        });
        table.on('tool(list)', function(obj) {
            var data = obj.data;
            if (obj.event === 'del') {
                layer.confirm('您确定未收到货款吗？', function(index){
                    var loading = layer.load(1, {shade: [0.1, '#fff']});
                    $.post("{:url('bohuibaodan')}",{id:data.bid},function(res){
                        layer.close(loading);
                        if(res.code===1){
                            layer.msg(res.msg,{time:1000,icon:1});
                            tableIn.reload();
                        }else{
                            layer.msg('操作失败！',{time:1000,icon:2});
                        }
                    });
                    layer.close(index);
                });
            }
			  if (obj.event === 'dakuan') {
                layer.confirm('您确定收到货款了吗？', function(index){
                    var loading = layer.load(1, {shade: [0.1, '#fff']});
                    $.post("{:url('baodanok')}",{id:data.bid},function(res){
                        layer.close(loading);
                        if(res.code===1){
                            layer.msg(res.msg,{time:1000,icon:1});
                            tableIn.reload();
                        }else{
                            layer.msg('操作失败！',{time:1000,icon:2});
                        }
                    });
                    layer.close(index);
                });
            }
        });

        $('#delAll').click(function(){
            layer.confirm('确认要删除选中信息吗？', {icon: 3}, function(index) {
                layer.close(index);
                var checkStatus = table.checkStatus('user'); //test即为参数id设定的值
                var ids = [];
                $(checkStatus.data).each(function (i, o) {
                    ids.push(o.id);
                });
                var loading = layer.load(1, {shade: [0.1, '#fff']});
                $.post("{:url('delall')}", {ids: ids}, function (data) {
                    layer.close(loading);
                    if (data.code === 1) {
                        layer.msg(data.msg, {time: 1000, icon: 1});
                        tableIn.reload();
                    } else {
                        layer.msg(data.msg, {time: 1000, icon: 2});
                    }
                });
            });
        })
    });
</script>
</body>
</html>